package work20241203_chap6oop.i_demo7;

/**
 * @author zdl
 * @date 2024/12/3
 */
class Super {
    public void m() {
        foo();
    }

    public void foo() {
        System.out.println("foo() in Super");
    }
}

class Sub extends Super {
    public void foo() {
        System.out.println("foo() in Sub");
    }
}

public class TestSuperSub {
    public static void main(String args[]) {
        Super s = new Sub(); //向上转型
        s.m();  //foo() in Sub
    }
}
